<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>替换</title>

	</head>

	<body>
		<div>过滤前的内容：</br>
			<textarea rows="10" cols="40" id="pre"></textarea>
			<input type="button" value="过滤" id="btn" />
		</div>
		<div>过滤后的内容：</br>
			<textarea rows="10" cols="40" id="res"></textarea>
		</div>
		<script>
			var btn = document.getElementById('btn')
			btn.onclick = function() {
				var str = document.getElementById('pre').value
				var reg = /([bad]|[\u4e00-\u9fa5])/g;
				var newStr = str.replace(reg, '*');
				document.getElementById('res').innerHTML = newStr
			}
		</script>
	</body>

</html>